﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.Text;
using NUnit.Framework;

namespace Common.Tests.Text
{
    [TestFixture]
    public class CharacterEncoderTests
    {

        [Test]
        public void Encode_string_as_html()
        {
            const string csharp = "string[] str = StringBuilder.Build<string>(\"dddd\")";
            var result = CharacterEncoder.Encode(csharp);
            
            Assert.AreEqual("string[] str = StringBuilder.Build&lt;string&gt;(&quot;dddd&quot;)", result);
        }

        [TestCase("\"", ExpectedResult = "&quot;")]
        [TestCase("&", ExpectedResult = "&amp;")]
        [TestCase("<", ExpectedResult = "&lt;")]
        [TestCase(">", ExpectedResult = "&gt;")]
        [TestCase("\'", ExpectedResult = "&apos;")]
        [TestCase(@"\", ExpectedResult = @"\\")]
        [TestCase("{", ExpectedResult = "\\{")]
        [TestCase("}", ExpectedResult = "\\}")]
        [TestCase("", ExpectedResult = "")]
        public string Encode(string input)
        {
            return CharacterEncoder.Encode(input);
        }

    }
}
